﻿using Slippor.Douban.Radio.Search;
using Slippor.Douban.Radio.Assist;
using System.Web;
using System.Text;
using System;

namespace VeryCDSearchPlugin
{
    public class XiamiSearch : BaseSearch,ISearchAlbum,ISearchArtist
    {
        public XiamiSearch()
        {
            _searchUrl = "http://www.xiami.com/search/song/?key={0}";
            _name = "虾米";
            _encoder = "utf-8";
        }

        #region ISearchArtist Members

        public void SearchArtist(String artist)
        {
            String searchUrl = String.Format("http://www.xiami.com/search/find?artist={0}", HttpUtility.UrlEncode( artist,Encoding.GetEncoding(_encoder)));
            RadioUtility.Browse(searchUrl);
        }

        #endregion

        #region ISearchAlbum Members

        public void Search(Album album)
        {
            String searchUrl = String.Format("http://www.xiami.com/search/find?album={0}", HttpUtility.UrlEncode( album.Name,Encoding.GetEncoding(_encoder)));
            RadioUtility.Browse(searchUrl);
        }

        #endregion
    }
}